#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
int a[N];
int b[N], num;
int l[405], r[405], bid[N];
struct Node {
  int l, r, k;
  int id;
  bool operator<(const Node& o) const {
    if (bid[l] == bid[o.l]) {
      if (bid[l] & 1)
        return r < o.r;
      else
        return r > o.r;
    } else
      return l < o.l;
  }
} ask[N];
int ans[N];

void init() {
  int k = sqrt(n);
  rep(i, 1, n) bid[i] = (i - 1) / k + 1;
}
int bit[N];
int lowbit(int x) { return x & -x; }
void add(int x, int d) {
  for (int i = x; i <= num; i += lowbit(i)) bit[i] += d;
}
int query(int x) {
  int res = 0;
  for (int i = x; i; i -= lowbit(i)) res += bit[i];
  return res;
}
int L = 1, R = 0;
void add(int x) { add(a[x], 1); }
void del(int x) { add(a[x], -1); }
int get(int k) {
  int l = 1, r = num;
  while (l <= r) {
    int mid = (l + r) >> 1;
    int cnt = query(mid);
    if (cnt >= k)
      r = mid - 1;
    else
      l = mid + 1;
  }
  return b[l];
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 1, n) cin >> a[i];
  rep(i, 1, n) b[i] = a[i];
  sort(b + 1, b + n + 1);
  num = unique(b + 1, b + n + 1) - b - 1;
  rep(i, 1, n) a[i] = lower_bound(b + 1, b + n + 1, a[i]) - b;
  init();
  rep(i, 1, m) cin >> ask[i].l >> ask[i].r >> ask[i].k;
  rep(i, 1, m) ask[i].id = i;
  sort(ask + 1, ask + m + 1);
  rep(i, 1, m) {
    int l = ask[i].l, r = ask[i].r;
    while (r > R) add(++R);
    while (r < R) del(R--);
    while (l < L) add(--L);
    while (l > L) del(L++);
    ans[ask[i].id] = get(ask[i].k);
  }
  rep(i, 1, m) cout << ans[i] << endl;
  return 0;
}